#########################################################################
# File Name: pycdc-v0.4.py
# Author: Wulei
# mail: wlinpisces@gmail.com
# Created Time: Sun 23 Feb 2014 06:15:41 PM
#########################################################################
#!/usr/bin/env python
#coding=utf-8

import sys, cmd
from funcVersion import cdWalker,cdcGrep

class PyCDC(cmd.Cmd):
    def __init__(self):
        cmd.Cmd.__init__(self)

        self.prompt = '(pyCDC)>'
        self.intro = 'this is a demo -_-'
        self.CDROM = '/home/wulei/gitRepo/learingPython/'
        self.CDDIR = 'cday/'

    def help_EOF(self):
        print " quit the program"
    def do_EOF(self, line):
        sys.exit()

    def help_walk(self):
        print "walk cd and export into *.cdc"
    def do_walk(self, filename):
        if filename == "":
            filename = raw_input("input the filename:: ")
        print " save the content into: '%s'" % filename
        cdWalker(self.CDROM, self.CDROM + self.CDDIR+filename)

    def help_dir(self):
        print 'name the dir'
    def do_dir(self, pathname):
        if pathname == "":
            pathname = raw_input("input the dirname:: ")
        self.CDDIR = pathname
        print 'the determined dir:"%s";' % pathname

    def do_grepp(self,keyword):
        cdcGrep(self.CDROM+self.CDDIR, keyword)

if __name__ == '__main__':
    cdc = PyCDC()
    cdc.cmdloop()

    
